from django.conf import settings
from django.urls import path, re_path
from hot.views import account, user
from django.views.static import serve
from hot.views.index import Index
from api.views import get_data, post_liuyan, judge_phone
from hot.views import liuyan

urlpatterns = [
    # 添加media 配置
    re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
    re_path(r'^static/(?P<path>.*)$', serve, {'document_root': settings.STATIC_ROOT}, name='static'),

    path("home/", account.home, name='home'),

    # 账户
    path("login/", account.login, name='login'),
    path("logout/", account.logout, name='logout'),

    # 运营管理
    path("user/list/", user.list, name='user_list'),
    path("user/add/", user.add, name='user_add'),
    path("user/delete/", user.delete, name='user_delete'),
    path("user/delete_all/", user.delete_all, name='user_delete_all'),
    path("user/reset/<int:id>/", user.reset, name='user_reset'),
    path("user/edit/<int:id>/", user.edit, name='user_edit'),

    # api
    path("api/get_data/<name>/<int:priority>/", get_data, name='get_data'),
    path("api/post_liuyan/", post_liuyan, name='post_liuyan'),
    path("api/judge_phone/", judge_phone, name='judge_phone'),

    # 组件
    path('index/', Index.urls()),

    # 全局设置
    # path('global_setting/', account.global_setting , name='global_setting'),

    # 留言
    path('liuyan/list/', liuyan.list, name='liuyan'),
    path("liuyan/delete/", liuyan.delete, name='liuyan_delete'),
    path("liuyan/delete_all/", liuyan.delete_all, name='liuyan_delete_all'),
    path('export/csv/', liuyan.export, name='export_users_csv'),
]
